package com.flywen.utils;

import com.flywen.enums.IErrorCodeEnum;
import com.flywen.exception.AppException;
import com.flywen.generic.GenericResponse;
import org.apache.commons.lang3.StringUtils;

public class AssertUtils {
    private AssertUtils() {
    }

    public static void isNotBlank(String str, IErrorCodeEnum ErrorCodeEnum) {
        if (StringUtils.isBlank(str)) {
            throw new AppException(ErrorCodeEnum);
        }
    }

    public static void isAllNotBlank(String[] strs, IErrorCodeEnum ErrorCodeEnum) {
        String[] var5 = strs;
        int var4 = strs.length;

        for(int var3 = 0; var3 < var4; ++var3) {
            String str = var5[var3];
            isNotBlank(str, ErrorCodeEnum);
        }

    }

    public static void isNotBlank(String str, IErrorCodeEnum errorCodeEnum, String msg) {
        if (StringUtils.isBlank(str)) {
            throw new AppException(errorCodeEnum, msg);
        }
    }

    public static void isTrue(boolean bool, IErrorCodeEnum ErrorCodeEnum) {
        if (!bool) {
            throw new AppException(ErrorCodeEnum);
        }
    }

    public static void isTrue(boolean bool, IErrorCodeEnum ErrorCodeEnum, String message) {
        if (!bool) {
            throw new AppException(ErrorCodeEnum, message);
        }
    }

    public static <T> void isSuccess(GenericResponse<T> response) {
        isTrue(response.isSuccess(), response.getResponseCode(), response.getResponseMsg());
    }

    public static <T> void isSuccess(GenericResponse<T> response, IErrorCodeEnum errorCodeEnum) {
        isTrue(response.isSuccess(), errorCodeEnum.getResponseCode(), errorCodeEnum.getResponseMsg());
    }

    public static void isTrue(boolean bool, String responseCode, String responseMsg) {
        if (!bool) {
            throw new AppException(responseCode, responseMsg);
        }
    }

    public static void isNotNull(Object object, IErrorCodeEnum ErrorCodeEnum) {
        if (object == null) {
            throw new AppException(ErrorCodeEnum);
        }
    }

    public static void isNotNull(Object object, IErrorCodeEnum ErrorCodeEnum, String message) {
        if (object == null) {
            throw new AppException(ErrorCodeEnum, message);
        }
    }
}
